package com.example.lanqiaodemo1.java10plus;

import java.util.ArrayList;
import java.util.List;

public class EmployeeManage {
    static List<Employee> list = new ArrayList<>();

    public static double getAverageAge() {
        double sum = 0;
        for (Employee e : list) {
            sum += e.getAge();
        }
        return sum/list.size();

    }

    public static void addEmployee(Employee e) {
        list.add(e);
    }

    public static void main(String[] args) {
        Employee e = new Employee("1", "sadsa", 20);
        Employee e2 = new Employee("2", "1231", 99);
        Employee e3 = new Employee("4", "1231", 9999);
        addEmployee(e);
        addEmployee(e2);
        addEmployee(e3);
        System.out.println(getAverageAge());
    }
}

class Employee {
    private String ID;
    private String name;
    private int age;

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Employee(String ID, String name, int age) {
        this.ID = ID;
        this.name = name;
        this.age = age;
    }

    public Employee() {}

}
